# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=py3-libarchive-c
pkgver=5.1
pkgrel=1
pkgdesc="Python interface to libarchive"
url="https://github.com/Changaco/python-libarchive-c"
arch="noarch"
license="CC0-1.0"
depends="libarchive python3" # uses ffi
makedepends="python3-dev libarchive-dev py3-setuptools"
checkdepends="py3-pytest py3-mock"
subpackages="$pkgname-pyc"
source="python-libarchive-c-$pkgver.tar.gz::https://github.com/Changaco/python-libarchive-c/archive/$pkgver.tar.gz
	fix-test-entry-testtar.patch
	"
builddir="$srcdir/python-libarchive-c-$pkgver"

prepare() {
	default_prepare
	soname=$(scanelf --quiet --soname /usr/lib/libarchive.so | awk '{print $1}')
	sed -i -e "s/find_library('archive')/find_library('$soname')/" libarchive/ffi.py
}

build() {
	python3 setup.py build
}

check() {
	pytest
}

package() {
	python3 setup.py install --skip-build --root="$pkgdir"
}

sha512sums="
ed13687709370a828df584601852af2de9ec93091072242254192e7eb425c754e7d1467eb9692691ce971f2a6c3d5f6ee8c78a21b0262b0cc2c15ae31c03d680  python-libarchive-c-5.1.tar.gz
af20e8813377aecdff5425cb06fbcc0207b55809f0af7f4d3c7949941187e8e33e9f9e350438f45699be4abd4ccff27f852e4edf9ae67beee39f83524a49fc9e  fix-test-entry-testtar.patch
"
